echo -n 'enter the new component name: '                   # 参数-n的作用是不换行，echo默认换行
read  compName
# 转小写
typeset -l filename
# shell 变量名与等号间不能添加空格
basePath='./src/components'
filename=$compName

mkdir ./src/components/$compName

indexTemplate="import $compName from './$filename'
export default $compName

export * from './config'
export * from './$filename'
"

compTemplate="import React from 'react'
import { "$compName"Props } from './config'

const $compName: React.FC<"$compName"Props> = props => {
  return <></>
}
export default $compName
"

configTemplate="import React from 'react'
import classNames from 'classnames'

export interface "$compName"Props {}

// 获取组件配置的class
export const get"$compName"ClassNames = (props: "$compName"Props) => {}
"

touch $basePath/$compName/_style.scss
touch $basePath/$compName/index.tsx
touch $basePath/$compName/$filename.tsx
touch $basePath/$compName/config.tsx

echo "$indexTemplate" >> $basePath/$compName/index.tsx
echo "$compTemplate" >> $basePath/$compName/$filename.tsx
echo "$configTemplate" >> $basePath/$compName/config.tsx

echo "@import '../components/$compName/style';" >> ./src/styles/index.scss